package utils

import (
	"sharePicture/models/page"
)

// 设置分页信息除具体数据外
func SetPageInfo(pageNum int, pageSize int, pageCount int64) page.PageInfo {
	pageInfo := page.PageInfo{}
	if pageCount <= 0 {
		return pageInfo
	}

	pageInfo.Total = pageCount
	pageInfo.PageNum = pageNum
	pageInfo.PageSize = pageSize
	pageInfo.Pages = (int(pageCount-1) / pageSize) + 1
	if pageInfo.Pages > pageNum {
		pageInfo.HasNextPage = true
		pageInfo.NextPage = pageNum + 1
	} else {
		pageInfo.IsLastPage = true
	}
	if pageNum > 1 {
		pageInfo.HasPreviousPage = true
		pageInfo.PrePage = pageNum - 1
	} else {
		pageInfo.IsFirstPage = true
	}

	return pageInfo

}
